package com.prs.crm.dao.cqunicom.impl;

import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;

import com.prs.crm.dao.cqunicom.MidBusinessOrderDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.cqunicom.Company;
import com.prs.crm.domain.cqunicom.MidBusinessOrder;
import com.prs.crm.domain.cqunicom.PoplarOrder;
import com.prs.crm.domain.cqunicom.Services;

/**
 * @author LanXiaoGang
 * @E-mail:lan9liang@163.com
 * @qq:7857553326
 * @version 创建时间：2011-3-17 上午11:50:44
 * 简单说明
 */

public class MidBusinessOrderDaoImpl extends BaseDaoImpl<MidBusinessOrder>
		implements MidBusinessOrderDao {

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public List<MidBusinessOrder> getMidBusinessOrder(final Services servicesm) {
		 return (List<MidBusinessOrder>) this.getHibernateTemplate().execute(
					new HibernateCallback()
					{
						public Object doInHibernate(Session session) throws HibernateException {
				        	Criteria criteria = session.createCriteria(MidBusinessOrder.class);
				        	criteria.add(Restrictions.eq("servicesm",servicesm));
				        
							return criteria.list();
				 				        	
				        }
					}
			);
	}
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public List<MidBusinessOrder> getMidBusinessOrderBycomp(final Company companym) {
		 return (List<MidBusinessOrder>) this.getHibernateTemplate().execute(
					new HibernateCallback()
					{
						public Object doInHibernate(Session session) throws HibernateException {
				        	Criteria criteria = session.createCriteria(MidBusinessOrder.class);
				        	criteria.add(Restrictions.eq("companym",companym));				        	
							return criteria.list();
				 				        	
				        }
					}
			);
	}
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public List<MidBusinessOrder> getBybusAndCom(final Services servicesm,
			final	Company companym) {
		return (List<MidBusinessOrder>) this.getHibernateTemplate().execute(
				new HibernateCallback()
				{
					public Object doInHibernate(Session session) throws HibernateException {
			        	Criteria criteria = session.createCriteria(MidBusinessOrder.class);
			        	criteria.add(Restrictions.eq("companym",companym));		
			        	criteria.add(Restrictions.eq("servicesm",servicesm));	
						return criteria.list();
			 				        	
			        }
				}
		);
	}

}
